package aleetcode;

import java.util.Arrays;
import java.util.Scanner;

public class _1 {
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        System.out.println("请输入数组长度:");
        int n=scan.nextInt();
        int []nums=new int[n];
        for(int i=0;i<n;i++){
            System.out.println("请输入第"+(i+1)+"个数:");
            nums[i]=scan.nextInt();
        }
        System.out.println(Arrays.toString(nums));
        int target;
        System.out.println("请输入目标值:");
        target = scan.nextInt();
        Solution1 so=new Solution1();
        int []result=so.twoSum(nums,target);
        System.out.println(Arrays.toString(result));
    }
}
class Solution1 {
    public int[] twoSum(int[] nums, int target) {
        int []result=new int[2];
        for(int i=0;i<nums.length;i++){
            for (int j=i+1;j<nums.length;j++){
                if(nums[i]+nums[j]==target)
                {
                    result[0]=i;
                    result[1]=j;
                }
            }
        }

        return result;
    }
}